package com.wanbatv.wangwangba;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.wanbatv.kit.messenger.Letter;
import com.wanbatv.kit.messenger.MessageSubscriber;
import com.wanbatv.kit.messenger.MessengerClient;
import com.wanbatv.kit.messenger.Option;
import com.wanbatv.kit.net.DefaultRequest;
import com.wanbatv.kit.net.DefaultResponse;
import com.wanbatv.kit.net.NetworkException;
import com.wanbatv.kit.net.alipay.AlipayHttpClient;
import com.wanbatv.kit.net.alipay.AlipayTradePrecreateBuilder;
import com.wanbatv.kit.net.alipay.AlipayTradePrecreateResult;
import com.wanbatv.wangwangba.Pager.page1;
import com.wanbatv.wangwangba.Pager.page2;
import com.wanbatv.wangwangba.Pager.page3;
import com.wanbatv.wangwangba.Pager.page4;
import com.wanbatv.wangwangba.Pager.page5;
import com.wanbatv.wangwangba.util.AppUtil;
import com.wanbatv.wangwangba.util.DownloadTask;
import com.wanbatv.wangwangba.util.DownloadTaskReceiver;
import com.wanbatv.wangwangba.util.FocusImageView;
import com.wanbatv.wangwangba.util.TVViewPager;
import com.wanbatv.wangwangba.util.Util;
import com.wanbatv.wangwangba.utils.Product;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;

//import com.xiaomi.mistatistic.sdk.MiStatInterface;


public class Login2Activity extends Activity {
    public static Login2Activity thelogin2;
    TVViewPager viewpager;
    ArrayList<View> viewContainter = new ArrayList<View>();
    private TextView tuijian_tv1;
    private TextView tuijian_tv2;
    private TextView tuijian_tv3;
    private TextView tuijian_tv4;
    private TextView tuijian_tv5;
    private RelativeLayout new_bg;
    int YEMA_NUM=1;
    private AlertDialog myDialog=null;
    private WangwangbaAdapter mAdpater=null;
    public static int DOGTV_NUM=0;
    public static  boolean IS_SHANG=true;
    float currentSize ;
    float normalSize ;

    DownloadTaskReceiver receiver;
    public static int DOGTV_NUM_XUANZE=0;
    public static int XIAOBAIKE_NUM_XUANZE=0;

    private JSONArray baike_arr=null;
    private JSONArray tuijian_arr=null;
    private JSONArray wangwangshow_arr=null;
    private JSONObject dogtv_arr=null;

    public static String baike_token=null;
    public static String shipin_url=null;
    public static String shipin_url11=null;
    public static String shipin_url12=null;
    public static String shipin_url13=null;
    public static String shipin_url14=null;
    public static String shipin_url15=null;
    public static String shipin_url16=null;
    public static String shipin_url17=null;
    public static String shipin_url18=null;
    public static String shipin_url19=null;
    public static String shipin_url110=null;
    public static String dizhi=null;
    public static String dizhi11=null;
    public static String dizhi12=null;
    public static String dizhi13=null;
    public static String dizhi14=null;
    public static String dizhi15=null;
    public static String dizhi16=null;
    public static String dizhi17=null;
    public static String dizhi18=null;
    public static String dizhi19=null;
    public static String dizhi110=null;

    public static boolean url_wws11=false;
    public static boolean url_wws12=false;
    public static boolean url_wws13=false;
    public static boolean url_wws14=false;
    public static boolean url_wws15=false;
    public static boolean url_wws16=false;
    public static boolean url_wws17=false;
    public static boolean url_wws18=false;
    public static boolean url_wws19=false;
    public static boolean url_wws110=false;
    private boolean YEMA_NUM_B2=false;
    private boolean YEMA_NUM_B3=false;
    private boolean YEMA_NUM_B4=false;
    private boolean YEMA_NUM_B5=false;
    public void huoqu_url1(String url){
        shipin_url11=url;
    }
    public void huoqu_url2(String url){
        shipin_url12=url;
    }
    public void huoqu_url3(String url){
        shipin_url13=url;
    }
    public void huoqu_url4(String url){
        shipin_url14=url;
    }
    public void huoqu_url5(String url){
        shipin_url15=url;
    }

    public void huoqu_url6(String url){
        shipin_url16=url;
    }
    public void huoqu_url7(String url){
        shipin_url17=url;
    }
    public void huoqu_url8(String url){
        shipin_url18=url;
    }
    public void huoqu_url9(String url){
        shipin_url19=url;
    }
    public void huoqu_url10(String url){
        shipin_url110=url;
    }
    public void huoqu_url(String url){
        shipin_url=url;
    }
    private Map<String,Bitmap> map=new HashMap<String,Bitmap>();
    private RelativeLayout dinggou_yemian;
    private RelativeLayout zhifu_yemian;
    private ImageView dinggou_anniu1;
    private ImageView dinggou_anniu2;
    private ImageView dinggou_anniu3;
    Animation translateAnimation;
    Animation translateAnimation1;
    int NUM_DINGGOU=0;

    private boolean IF_ZHIFU=false;
    private JSONArray arr_zhifubao=null;
    private JSONObject obj_zhifubao=null;
    private String order;
    private String sign;
    RelativeLayout chengzhang_rela1;
    RelativeLayout chengzhang_rela2;
    FocusImageView chengzhang_queding;
    JSONObject chengzhang_obj=null;
    String url_zhengshi="http://121.201.14.248:8062";
    String url_ceshi="http://121.201.7.173:8087";
    View view_shuaxin=null;
    public static int chengzhang_num1=0;
    public static int chengzhang_num2=0;
    public static int chengzhang_num3=0;
    public static int chengzhang_num4=0;
    public static int chengzhang_num_pindao=0;
    private ImageView zhifubao_erweima;

    private AlipayHttpClient mAlipayHttpClient = null;
    private MessengerClient mMessengerClient = null;
    private MessageSubscriberImpl mMessageSubscriber = new MessageSubscriberImpl();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login2);
        updataAPK("http://121.201.14.248:8061/dogtv/getversion?flavor=" + Product.flavor + "&type=release&productname=wangwangba&platform=android",
                AppUtil.converVersionNameToInt(AppUtil.getAppVersionName(this)));
//        MiStatInterface.initialize(this, "2882303761517361951", "5661736182951", "xiaomi");

        Option option = new Option();
        option.appId = Product.appId;
        option.appKey = Product.appKey;
        option.group = Product.flavor;
        option.device = Util.getDeviceId(this);
        mMessengerClient = MessengerClient.getInstance(this, option);

        dinggou_yemian=(RelativeLayout)findViewById(R.id.dinggou_yemian);
        zhifu_yemian=(RelativeLayout)findViewById(R.id.zhifu_yemian);
        zhifubao_erweima=(ImageView)findViewById(R.id.zhifubao_erweima);
        dinggou_anniu1=(ImageView)findViewById(R.id.dinggou_anniu1);
        dinggou_anniu2=(ImageView)findViewById(R.id.dinggou_anniu2);
        dinggou_anniu3=(ImageView)findViewById(R.id.dinggou_anniu3);

        //初始化支付宝开放接口
        mAlipayHttpClient = new AlipayHttpClient(this.getApplicationContext());

        dinggou_anniu3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dinggou_yemian.setVisibility(View.GONE);
                all_foucs_yes();
                dinggou_foucs();
                translateAnimation= new TranslateAnimation( 0,2000,0,0);
                translateAnimation.setDuration(1000);
                dinggou_yemian.setAnimation(translateAnimation);
            }
        });
        dinggou_anniu1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                image_fangda(v,true);
                zhifu_yemian.setVisibility(View.VISIBLE);
                try {
                    JSONObject obj=arr_zhifubao.getJSONObject(0);
                    final   String subject=obj.getString("subject");
                    final   String subjectid=obj.getString("subjectId");
                    final   String price=obj.getString("price");
                    RequestQueue requestQueue = Volley.newRequestQueue(Login2Activity.this);
                    String url="http://121.201.7.173:8087/api/common/wpay/getorder";
                    StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                            new Response.Listener<String>() {
                                @Override
                                public void onResponse(String response) {
                                    try {
                                        obj_zhifubao= (JSONObject) new JSONTokener(response).nextValue();
                                        JSONObject oobj=obj_zhifubao.getJSONObject("data");
                                        order=oobj.getString("order");
                                        AlipayTradePrecreateBuilder builder = new AlipayTradePrecreateBuilder()
                                                .outTradeNo(order)
                                                .subject(subject)
                                                .totalAmount(Float.parseFloat(price));

                                        mAlipayHttpClient.enqueue(builder.create(), new DefaultResponse.OnResponseListener() {
                                            @Override
                                            public void onResponse(DefaultResponse response) {
                                                final AlipayTradePrecreateResult aliResponse =
                                                        (AlipayTradePrecreateResult) response.result();
                                                final String qrCode = aliResponse.qrCode();
                                                new Handler(Looper.getMainLooper()).post(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        if(qrCode!=null){
                                                            createImage(zhifubao_erweima,qrCode);
                                                        }
                                                    }
                                                });
                                            }

                                            @Override
                                            public void onFailure(DefaultRequest request, NetworkException e) {

                                            }
                                        });
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            error.printStackTrace();
                        }
                    }) {
                        @Override
                        public Map<String, String> getHeaders() throws AuthFailureError {
                            HashMap<String, String> headers = new HashMap<String, String>();
                            PackageInfo pi= null;
                            try {
                                pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                                headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                                headers.put("app_version", pi.versionName);
                                headers.put("app_package_name",pi.packageName);
                            } catch (PackageManager.NameNotFoundException e) {
                                e.printStackTrace();
                            }


                            // MyLog.d(TAG, "headers=" + headers);
                            return headers;
                        }
                        @Override
                        public String getBodyContentType() {
                            return "application/x-www-form-urlencoded; charset=" + getParamsEncoding();
                        }

                        @Override
                        protected Map<String, String> getParams() throws AuthFailureError {
                            HashMap<String, String> params = new HashMap<String, String>();
                            params.put("partner","1156");
                            params.put("subject", subject);
                            params.put("subjectid",subjectid);
                            params.put("price",price);
                            params.put("provider","openalipay");
                            params.put("stb",Util.getDeviceId(Login2Activity.this));
                            params.put("flavor", Product.flavor);
                            return params;
                        }
                    };
                    requestQueue.add(stringRequest);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        dinggou_anniu2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                image_fangda(v, true);
                zhifu_yemian.setVisibility(View.VISIBLE);
                try {
                    JSONObject obj=arr_zhifubao.getJSONObject(1);
                    final   String subject=obj.getString("subject");
                    final   String subjectid=obj.getString("subjectId");
                    final   String price=obj.getString("price");
                    RequestQueue requestQueue = Volley.newRequestQueue(Login2Activity.this);
                    String url="http://121.201.14.248:8062/api/common/wpay/getorder";
                    StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
                            new Response.Listener<String>() {
                                @Override
                                public void onResponse(String response) {
                                    try {
                                        obj_zhifubao= (JSONObject) new JSONTokener(response).nextValue();
                                        JSONObject oobj=obj_zhifubao.getJSONObject("data");
                                        order=oobj.getString("order");
                                        AlipayTradePrecreateBuilder builder = new AlipayTradePrecreateBuilder()
                                                .outTradeNo(order)
                                                .subject(subject)
                                                .totalAmount(Float.parseFloat(price));
                                        mAlipayHttpClient.enqueue(builder.create(), new DefaultResponse.OnResponseListener() {
                                            @Override
                                            public void onResponse(DefaultResponse response) {
                                                final AlipayTradePrecreateResult aliResponse =
                                                        (AlipayTradePrecreateResult) response.result();
                                                final String qrCode = aliResponse.qrCode();
                                                new Handler(Looper.getMainLooper()).post(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        if(qrCode!=null){
                                                            createImage(zhifubao_erweima,qrCode);
                                                        }
                                                    }
                                                });
                                            }

                                            @Override
                                            public void onFailure(DefaultRequest request, NetworkException e) {

                                            }
                                        });
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }
                                }
                            }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            error.printStackTrace();
                        }
                    }) {
                        @Override
                        public Map<String, String> getHeaders() throws AuthFailureError {
                            HashMap<String, String> headers = new HashMap<String, String>();
                            PackageInfo pi= null;
                            try {
                                pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                                headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                                headers.put("app_version", pi.versionName);
                                headers.put("app_package_name",pi.packageName);
                            } catch (PackageManager.NameNotFoundException e) {
                                e.printStackTrace();
                            }


                            // MyLog.d(TAG, "headers=" + headers);
                            return headers;
                        }
                        @Override
                        public String getBodyContentType() {
                            return "application/x-www-form-urlencoded; charset=" + getParamsEncoding();
                        }

                        @Override
                        protected Map<String, String> getParams() throws AuthFailureError {
                            HashMap<String, String> params = new HashMap<String, String>();
                            params.put("partner","1156");
                            params.put("subject", subject);
                            params.put("subjectid",subjectid);
                            params.put("price",price);
                            params.put("provider","openalipay");
                            params.put("stb",Util.getDeviceId(Login2Activity.this));
                            params.put("flavor", Product.flavor);
                            return params;
                        }
                    };
                    requestQueue.add(stringRequest);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        dinggou_anniu1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    image_fangda(v,true);
                }else{
                    image_fangda(v,false);
                }
            }
        });
        dinggou_anniu2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    image_fangda(v,true);
                }else{
                    image_fangda(v,false);
                }
            }
        });
        dinggou_anniu3.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    image_fangda(v,true);
                }else{
                    image_fangda(v,false);
                }
            }
        });
        viewpager=(TVViewPager)findViewById(R.id.viewpager);
        viewpager.setOffscreenPageLimit(4);
        viewpager.setPageMargin(-300);
        tuijian_tv1=(TextView)findViewById(R.id.tuijian_tv1);
        tuijian_tv2=(TextView)findViewById(R.id.tuijian_tv2);
        tuijian_tv3=(TextView)findViewById(R.id.tuijian_tv3);
        tuijian_tv4=(TextView)findViewById(R.id.tuijian_tv4);
        tuijian_tv5=(TextView)findViewById(R.id.tuijian_tv5);
        new_bg=(RelativeLayout)findViewById(R.id.new_bg);
         currentSize = getResources().getDimension(R.dimen.text_bianda);
         normalSize = getResources().getDimension(R.dimen.text_bianxiao);
        textsizechange();
        tuijian_tv1.setTextSize(currentSize);
        View view1 = LayoutInflater.from(this).inflate(R.layout.page1, null);
        final View view2 = LayoutInflater.from(this).inflate(R.layout.page2, null);
        View view3 = LayoutInflater.from(this).inflate(R.layout.page3, null);
        View view4 = LayoutInflater.from(this).inflate(R.layout.page4, null);
        View view5 = LayoutInflater.from(this).inflate(R.layout.page5, null);
        view_shuaxin=view2;
        viewContainter.add(view1);
        viewContainter.add(view2);
        viewContainter.add(view3);
        viewContainter.add(view4);
        viewContainter.add(view5);
        chengzhang_rela1=(RelativeLayout)view2.findViewById(R.id.chengzhang_rela1);
        chengzhang_rela2=(RelativeLayout)view2.findViewById(R.id.chengzhang_rela2);
        chengzhang_queding=(FocusImageView)view2.findViewById(R.id.chengzhang_queding);
        chengzhang_queding.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                    RequestQueue rq = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
                    JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wangwangba/data.jsp?userId="+ Util.getDeviceId(Login2Activity.this), null,
                            new Response.Listener<JSONObject>() {

                                @Override
                                public void onResponse(JSONObject jsonObject) {
                                    chengzhangjirishuaxin(jsonObject,view2);

                                    try {
                                        JSONArray arr=jsonObject.getJSONArray("userList");
                                        if(arr.length()==0){
                                            Toast.makeText(Login2Activity.this,"请先扫描二维码",Toast.LENGTH_LONG).show();
                                        }else{
                                            chengzhang_rela1.setVisibility(View.VISIBLE);
                                            chengzhang_rela2.setVisibility(View.GONE);
                                            chengzhangjirishuaxin(jsonObject, view2);
                                            tuijian_tv2.requestFocus();
                                        }
                                    } catch (JSONException e) {
                                        e.printStackTrace();
                                    }

                                }
                            }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError volleyError) {
                        }
                    }

                    );
                    rq.add(request);




            }
        });
        mAdpater=new WangwangbaAdapter();
        viewpager.setAdapter(mAdpater);
                viewpager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
                    @Override
                    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

                    }

                    @Override
                    public void onPageSelected(int position) {
                        if (IS_SHANG == false) {
                            switch (position) {
                                case 0:
                                    if (YEMA_NUM == 2) {
                                        page1.tuijian_iv4.requestFocus();
                                        YEMA_NUM = 1;
                                    }
                                    break;
                                case 1:
                                    if (YEMA_NUM == 1) {
                                        if(chengzhang_rela1.getVisibility()==View.VISIBLE) {
                                            page2.chengzhang_gengduo_iv.requestFocus();
                                        }else {
                                            chengzhang_queding.requestFocus();
                                        }
                                        YEMA_NUM = 2;
                                    }
                                    if (YEMA_NUM == 3) {
                                        if(chengzhang_rela1.getVisibility()==View.VISIBLE) {
                                            page2.chengzhang_iv4.requestFocus();
                                        }else {
                                            chengzhang_queding.requestFocus();
                                        }
                                        YEMA_NUM = 2;
                                    }
                                    break;
                                case 2:
                                    if (YEMA_NUM == 2) {
                                        page3.dogtv_iv1.requestFocus();
                                        YEMA_NUM = 3;
                                    }
                                    if (YEMA_NUM == 4) {
                                        page3.dogtv_iv6.requestFocus();
                                        YEMA_NUM = 3;
                                    }
                                    break;
                                case 3:
                                    if (YEMA_NUM == 3) {
                                        page4.baike_iv1.requestFocus();
                                        YEMA_NUM = 4;
                                    }
                                    if (YEMA_NUM == 5) {
                                        page4.baike_iv5.requestFocus();
                                        YEMA_NUM = 4;
                                    }
                                    break;
                                case 4:
                                    page5.wangwangshow_iv1.requestFocus();
                                    YEMA_NUM = 5;
                                    break;
                            }

                        }
                        switch (position) {
                            case 0:
                                textcolor();
                                tuijian_tv1.setTextColor(0xfffff799);
                                textsizechange();
                                tuijian_tv1.setTextSize(currentSize);
//                                new_bg.setBackgroundResource(R.drawable.loginbg_new1);
                                break;
                            case 1:
                                textcolor();
                                tuijian_tv2.setTextColor(0xfffff799);
                                textsizechange();
                                tuijian_tv2.setTextSize(currentSize);
//                                new_bg.setBackgroundResource(R.drawable.loginbg_new1);
                                if(!YEMA_NUM_B2) {
                                    RequestQueue rq = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
//                                    JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wanba/photo_ajax_0907.jsp?userId=" + Util.getDeviceId(Login2Activity.this), null,
                                    JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wangwangba/data.jsp?userId="+ Util.getDeviceId(Login2Activity.this), null,
                                            new Response.Listener<JSONObject>() {

                                                @Override
                                                public void onResponse(JSONObject jsonObject) {
                                                    try {
                                                        JSONArray arr=jsonObject.getJSONArray("userList");
                                                        houtaibangding(arr);
                                                        if(arr.length()==0){
                                                            chengzhang_rela2.setVisibility(View.VISIBLE);
                                                            chengzhang_rela1.setVisibility(View.GONE);
                                                            RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                                            ImageRequest imageRequest1 = new ImageRequest("http://121.201.14.248"+
                                                                    jsonObject.getString("qrUrl"),
                                                                    new Response.Listener<Bitmap>() {
                                                                        @Override
                                                                        public void onResponse(Bitmap response) {
                                                                            ImageView iv1=(ImageView)view2.findViewById(R.id.chengzhang_erweima_iv2);
                                                                            iv1.setImageBitmap(response);
                                                                            map.put("dogtv_iv_erweima2", response);
                                                                        }
                                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                                @Override
                                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                                }
                                                            });
                                                            mQueue1.add(imageRequest1);
                                                        }else{
                                                            chengzhang_rela1.setVisibility(View.VISIBLE);
                                                            chengzhang_rela2.setVisibility(View.GONE);
                                                            chengzhangjirishuaxin(jsonObject,view2);
                                                        }
                                                        YEMA_NUM_B2=true;
                                                    } catch (JSONException e) {
                                                        e.printStackTrace();
                                                    }

                                                }
                                            }, new Response.ErrorListener() {
                                        @Override
                                        public void onErrorResponse(VolleyError volleyError) {
                                        }
                                    }

                                    );
                                    rq.add(request);
                                }
                                break;
                            case 2:
                                textcolor();
                                tuijian_tv3.setTextColor(0xfffff799);
                                textsizechange();
                                tuijian_tv3.setTextSize(currentSize);
//                                new_bg.setBackgroundResource(R.drawable.loginbg_new3);
                                if(!YEMA_NUM_B3){
                                    if(dogtv_arr!=null) {
                                        try {
                                            JSONArray dog_tv_arr = dogtv_arr.getJSONArray("list");
                                            JSONObject obj1 = dog_tv_arr.getJSONObject(0);
                                            String url1 = obj1.getString("cover_url");
                                            RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest1 = new ImageRequest(
                                                    url1,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page3.dogtv_iv1.setImageBitmap(response);
                                                            map.put("dogtv_iv1", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue1.add(imageRequest1);
                                            JSONObject obj2 = dog_tv_arr.getJSONObject(1);
                                            String url2 = obj2.getString("cover_url");
                                            RequestQueue mQueue2 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest2 = new ImageRequest(
                                                    url2,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page3.dogtv_iv2.setImageBitmap(response);
                                                            map.put("dogtv_iv2", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue2.add(imageRequest2);
                                            JSONObject obj3 = dog_tv_arr.getJSONObject(2);
                                            String url3 = obj3.getString("cover_url");
                                            RequestQueue mQueue3 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest3 = new ImageRequest(
                                                    url3,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page3.dogtv_iv3.setImageBitmap(response);
                                                            map.put("dogtv_iv3", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue3.add(imageRequest3);
                                            JSONObject obj4 = dog_tv_arr.getJSONObject(3);
                                            String url4 = obj4.getString("cover_url");
                                            RequestQueue mQueue4 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest4 = new ImageRequest(
                                                    url4,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page3.dogtv_iv4.setImageBitmap(response);
                                                            map.put("dogtv_iv4", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue4.add(imageRequest4);

                                            JSONObject obj_who = dogtv_arr.getJSONObject("welcome");

                                            String url5 = obj_who.getString("cover_url");
                                            RequestQueue mQueue5 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest5 = new ImageRequest(
                                                    url5,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page3.dogtv_iv5.setImageBitmap(response);
                                                            map.put("dogtv_iv5", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue5.add(imageRequest5);
                                            JSONObject obj_faq = dogtv_arr.getJSONObject("faq");
                                            String url6 = obj_faq.getString("cover_url");
                                            RequestQueue mQueue6 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest6 = new ImageRequest(
                                                    url6,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page3.dogtv_iv6.setImageBitmap(response);
                                                            map.put("dogtv_iv6", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue6.add(imageRequest6);
                                            YEMA_NUM_B3 = true;
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }
                                break;
                            case 3:
                                textcolor();
                                tuijian_tv4.setTextColor(0xfffff799);
                                textsizechange();
                                tuijian_tv4.setTextSize(currentSize);
//                                new_bg.setBackgroundResource(R.drawable.loginbg_new4);
                                if(!YEMA_NUM_B4){
                                    if(baike_arr!=null) {
                                        try {
                                            JSONObject obj1 = baike_arr.getJSONObject(0);
                                            String url1 = obj1.getString("cover_url");
                                            RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest1 = new ImageRequest(
                                                    url1,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page4.baike_iv1.setImageBitmap(response);
                                                            map.put("baike1", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue1.add(imageRequest1);
                                            JSONObject obj2 = baike_arr.getJSONObject(1);
                                            String url2 = obj2.getString("cover_url");
                                            RequestQueue mQueue2 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest2 = new ImageRequest(
                                                    url2,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page4.baike_iv2.setImageBitmap(response);
                                                            map.put("baike2", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue2.add(imageRequest2);
                                            JSONObject obj3 = baike_arr.getJSONObject(2);
                                            String url3 = obj3.getString("cover_url");
                                            RequestQueue mQueue3 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest3 = new ImageRequest(
                                                    url3,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page4.baike_iv3.setImageBitmap(response);
                                                            map.put("baike3", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue3.add(imageRequest3);
                                            JSONObject obj4 = baike_arr.getJSONObject(3);
                                            String url4 = obj4.getString("cover_url");
                                            RequestQueue mQueue4 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest4 = new ImageRequest(
                                                    url4,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page4.baike_iv4.setImageBitmap(response);
                                                            map.put("baike4", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue4.add(imageRequest4);
                                            JSONObject obj5 = baike_arr.getJSONObject(4);
                                            String url5 = obj5.getString("cover_url");
                                            RequestQueue mQueue5 = Volley.newRequestQueue(Login2Activity.this);

                                            ImageRequest imageRequest5 = new ImageRequest(
                                                    url5,
                                                    new Response.Listener<Bitmap>() {
                                                        @Override
                                                        public void onResponse(Bitmap response) {
                                                            page4.baike_iv5.setImageBitmap(response);
                                                            map.put("baike5", response);
                                                        }
                                                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                @Override
                                                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                }
                                            });
                                            mQueue5.add(imageRequest5);
                                            YEMA_NUM_B4 = true;
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                    }
                                }
                                break;
                            case 4:
                                textcolor();
                                tuijian_tv5.setTextColor(0xfffff799);
                                textsizechange();
                                tuijian_tv5.setTextSize(currentSize);
//                                new_bg.setBackgroundResource(R.drawable.loginbg_new5);
                                if(!YEMA_NUM_B5){
                                    if (wangwangshow_arr != null) {
                                        try {

                                                JSONObject obj1 = wangwangshow_arr.getJSONObject(0);
                                                String url1 = obj1.getString("cover_url");
                                                RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                                ImageRequest imageRequest1 = new ImageRequest(
                                                        url1,
                                                        new Response.Listener<Bitmap>() {
                                                            @Override
                                                            public void onResponse(Bitmap response) {
                                                                page5.wangwangshow_iv1.setImageBitmap(response);
                                                                map.put("wangwangshow1", response);
                                                            }
                                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                    @Override
                                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                    }
                                                });
                                                mQueue1.add(imageRequest1);
                                                JSONObject obj2 = wangwangshow_arr.getJSONObject(1);
                                                String url2 = obj2.getString("cover_url");
                                                RequestQueue mQueue2 = Volley.newRequestQueue(Login2Activity.this);

                                                ImageRequest imageRequest2 = new ImageRequest(
                                                        url2,
                                                        new Response.Listener<Bitmap>() {
                                                            @Override
                                                            public void onResponse(Bitmap response) {
                                                                page5.wangwangshow_iv2.setImageBitmap(response);
                                                                map.put("wangwangshow2", response);
                                                            }
                                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                    @Override
                                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                    }
                                                });
                                                mQueue2.add(imageRequest2);
                                                JSONObject obj3 = wangwangshow_arr.getJSONObject(2);
                                                String url3 = obj3.getString("cover_url");
                                                RequestQueue mQueue3 = Volley.newRequestQueue(Login2Activity.this);

                                                ImageRequest imageRequest3 = new ImageRequest(
                                                        url3,
                                                        new Response.Listener<Bitmap>() {
                                                            @Override
                                                            public void onResponse(Bitmap response) {
                                                                page5.wangwangshow_iv3.setImageBitmap(response);
                                                                map.put("wangwangshow3", response);
                                                            }
                                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                    @Override
                                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                    }
                                                });
                                                mQueue3.add(imageRequest3);
                                                JSONObject obj4 = wangwangshow_arr.getJSONObject(3);
                                                String url4 = obj4.getString("cover_url");
                                                RequestQueue mQueue4 = Volley.newRequestQueue(Login2Activity.this);

                                                ImageRequest imageRequest4 = new ImageRequest(
                                                        url4,
                                                        new Response.Listener<Bitmap>() {
                                                            @Override
                                                            public void onResponse(Bitmap response) {
                                                                page5.wangwangshow_iv4.setImageBitmap(response);
                                                                map.put("wangwangshow4", response);
                                                            }
                                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                    @Override
                                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                    }
                                                });
                                                mQueue4.add(imageRequest4);
                                                JSONObject obj5 = wangwangshow_arr.getJSONObject(4);
                                                String url5 = obj5.getString("cover_url");
                                                RequestQueue mQueue5 = Volley.newRequestQueue(Login2Activity.this);

                                                ImageRequest imageRequest5 = new ImageRequest(
                                                        url5,
                                                        new Response.Listener<Bitmap>() {
                                                            @Override
                                                            public void onResponse(Bitmap response) {
                                                                page5.wangwangshow_iv5.setImageBitmap(response);
                                                                map.put("wangwangshow5", response);
                                                            }
                                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                    @Override
                                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                    }
                                                });
                                                mQueue5.add(imageRequest5);
                                                JSONObject obj6 = wangwangshow_arr.getJSONObject(5);
                                                String url6 = obj6.getString("cover_url");
                                                RequestQueue mQueue6 = Volley.newRequestQueue(Login2Activity.this);

                                                ImageRequest imageRequest6 = new ImageRequest(
                                                        url6,
                                                        new Response.Listener<Bitmap>() {
                                                            @Override
                                                            public void onResponse(Bitmap response) {
                                                                page5.wangwangshow_iv6.setImageBitmap(response);
                                                                map.put("wangwangshow6", response);
                                                            }
                                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                                    @Override
                                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                                    }
                                                });
                                                mQueue6.add(imageRequest6);
                                                YEMA_NUM_B5 = true;
                                            }catch(JSONException e){
                                                e.printStackTrace();
                                            }
                                        }
                                }
                                break;

                        }
//                        mHandler.sendEmptyMessage(MSG_PLAY_PROGRESS);
                    }


                    @Override
                    public void onPageScrollStateChanged(int state) {

                    }
                });
        RequestQueue rq = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
        final JsonObjectRequest request = new JsonObjectRequest(url_zhengshi+"/api/wangwangba/wikis/all", null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {

                            JSONObject data=jsonObject.getJSONObject("data");
                            JSONArray arr=data.getJSONArray("list");
                            baike_arr=arr;
                            JSONObject faq=jsonObject.getJSONObject("faq");
                            baike_token=faq.getString("token");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                    headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };


        rq.add(request);

        RequestQueue rq1 = Volley.newRequestQueue(this.getApplicationContext());
        JsonObjectRequest request1 = new JsonObjectRequest(url_zhengshi+"/api/wangwangba/shows/all", null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            JSONArray arr=obj.getJSONArray("list");
                            wangwangshow_arr=arr;
                            JSONObject obj1=arr.getJSONObject(0);
                            JSONObject obj2=arr.getJSONObject(1);
                            JSONObject obj3=arr.getJSONObject(2);
                            JSONObject obj4=arr.getJSONObject(3);
                            JSONObject obj5=arr.getJSONObject(4);
                            JSONObject obj6=arr.getJSONObject(5);


                            dizhi11=obj1.getString("content_name");
                            dizhi12=obj2.getString("content_name");
                            dizhi13=obj3.getString("content_name");
                            dizhi14=obj4.getString("content_name");
                            dizhi15=obj5.getString("content_name");
                            dizhi16=obj6.getString("content_name");

                            huoqu_url1(obj1.getString("token"));
                            huoqu_url2(obj2.getString("token"));
                            huoqu_url3(obj3.getString("token"));
                            huoqu_url4(obj4.getString("token"));
                            huoqu_url5(obj5.getString("token"));
                            huoqu_url6(obj6.getString("token"));

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                    headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };

        rq1.add(request1);
        RequestQueue rq2 = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
        final JsonObjectRequest request2 = new JsonObjectRequest(url_zhengshi+"/api/wangwangba/hots/all", null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            JSONArray arr=obj.getJSONArray("list");
                            tuijian_arr=arr;
                            JSONObject obj1=arr.getJSONObject(0);
                            JSONArray arr1=obj1.getJSONArray("cover_urls");
                            if(arr1.length()>1){
                                String url=arr1.getString(1);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv6.setImageBitmap(response);
                                                map.put("tuijian6", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                                String url1=arr1.getString(0);
                                RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest1 = new ImageRequest(
                                        url1,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv1.setImageBitmap(response);
                                                map.put("tuijian1", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue1.add(imageRequest1);
                            }else{
                                String url=arr1.getString(0);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv1.setImageBitmap(response);
                                                map.put("tuijian1", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                            }
                            JSONObject obj2=arr.getJSONObject(1);
                            JSONArray arr2=obj2.getJSONArray("cover_urls");
                            if(arr2.length()>1){
                                String url=arr2.getString(1);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv7.setImageBitmap(response);
                                                map.put("tuijian7", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                                String url1=arr2.getString(0);
                                RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest1 = new ImageRequest(
                                        url1,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv2.setImageBitmap(response);
                                                map.put("tuijian2", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                            }else{
                                String url=arr2.getString(0);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv2.setImageBitmap(response);
                                                map.put("tuijian2", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                            }
                            JSONObject obj3=arr.getJSONObject(2);
                            JSONArray arr3=obj3.getJSONArray("cover_urls");
                            if(arr3.length()>1){
                                String url=arr3.getString(1);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv8.setImageBitmap(response);
                                                map.put("tuijian8", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                                String url1=arr3.getString(0);
                                RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest1 = new ImageRequest(
                                        url1,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv3.setImageBitmap(response);
                                                map.put("tuijian3", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue1.add(imageRequest1);
                            }else{
                                String url=arr3.getString(0);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv3.setImageBitmap(response);
                                                map.put("tuijian3", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                            }
                            JSONObject obj4=arr.getJSONObject(3);
                            JSONArray arr4=obj4.getJSONArray("cover_urls");
                            if(arr4.length()>1){
                                String url=arr4.getString(1);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv9.setImageBitmap(response);
                                                map.put("tuijian9", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                                String url1=arr4.getString(0);
                                RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest1 = new ImageRequest(
                                        url1,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv4.setImageBitmap(response);
                                                map.put("tuijian4", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue1.add(imageRequest1);
                            }else{
                                String url=arr4.getString(0);
                                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                                ImageRequest imageRequest = new ImageRequest(
                                        url,
                                        new Response.Listener<Bitmap>() {
                                            @Override
                                            public void onResponse(Bitmap response) {
                                                page1.tuijian_iv4.setImageBitmap(response);
                                                map.put("tuijian4", response);
                                            }
                                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                                    @Override
                                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                                    }
                                });
                                mQueue.add(imageRequest);
                            }


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {
            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                    headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };

        rq2.add(request2);
        RequestQueue rq3 = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
        final JsonObjectRequest request3 = new JsonObjectRequest(url_zhengshi+"/api/wangwangba/dogtvprograms/all", null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            dogtv_arr = obj;
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                    headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };


        rq3.add(request3);
        page1.tuijian_iv1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                all_false();
                baike_token=null;
                try {
                    JSONObject obj=tuijian_arr.getJSONObject(0);
                    if(obj.getInt("content_type")==1){
                        dizhi17=obj.getString("content_name");

                        huoqu_url7(obj.getString("token"));
                        url_wws17=true;
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, ShowBofangActivity.class);
                        startActivity(it);
                    }else{
                        baike_token=obj.getString("token");
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                        startActivity(it);
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        });
        page1.tuijian_iv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                baike_token=null;
                try {
                    JSONObject obj=tuijian_arr.getJSONObject(1);
                    if(obj.getInt("content_type")==1){
                        dizhi18=obj.getString("content_name");

                        huoqu_url8(obj.getString("token"));
                        url_wws18=true;
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, ShowBofangActivity.class);
                        startActivity(it);
                    }else{
                        baike_token=obj.getString("token");
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                        startActivity(it);
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        page1.tuijian_iv3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                all_false();
                baike_token=null;
                try {
                    JSONObject obj=tuijian_arr.getJSONObject(2);
                    if(obj.getInt("content_type")==1){
                        dizhi19=obj.getString("content_name");

                        huoqu_url9(obj.getString("token"));
                        url_wws19=true;
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, ShowBofangActivity.class);
                        startActivity(it);
                    }else{
                        baike_token=obj.getString("token");
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                        startActivity(it);
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        page1.tuijian_iv4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                all_false();
                baike_token=null;
                try {
                    JSONObject obj=tuijian_arr.getJSONObject(3);
                    if(obj.getInt("content_type")==1){
                        dizhi110=obj.getString("content_name");

                        huoqu_url10(obj.getString("token"));
                        url_wws110=true;
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, ShowBofangActivity.class);
                        startActivity(it);
                    }else{
                        baike_token=obj.getString("token");
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                        startActivity(it);
                    }

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        page4.baike_iv1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                XIAOBAIKE_NUM_XUANZE=0;
                try {
                    JSONObject obj=baike_arr.getJSONObject(XIAOBAIKE_NUM_XUANZE);
                    baike_token=obj.getString("token");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                Intent it = new Intent();
                it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                startActivity(it);
            }
        });
        page4.baike_iv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                XIAOBAIKE_NUM_XUANZE=1;
                try {
                    JSONObject obj=baike_arr.getJSONObject(XIAOBAIKE_NUM_XUANZE);
                    baike_token=obj.getString("token");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                Intent it = new Intent();
                it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                startActivity(it);
            }
        });
        page4.baike_iv3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                XIAOBAIKE_NUM_XUANZE=2;
                try {
                    JSONObject obj=baike_arr.getJSONObject(XIAOBAIKE_NUM_XUANZE);
                    baike_token=obj.getString("token");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                Intent it = new Intent();
                it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                startActivity(it);
            }
        });
        page4.baike_iv4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                XIAOBAIKE_NUM_XUANZE=3;
                try {
                    JSONObject obj=baike_arr.getJSONObject(XIAOBAIKE_NUM_XUANZE);
                    baike_token=obj.getString("token");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                Intent it = new Intent();
                it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                startActivity(it);
            }
        });
        page4.baike_iv5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                XIAOBAIKE_NUM_XUANZE=4;
                try {
                    JSONObject obj=baike_arr.getJSONObject(XIAOBAIKE_NUM_XUANZE);
                    baike_token=obj.getString("token");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                Intent it = new Intent();
                it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                startActivity(it);
            }
        });
        page3.dogtv_iv6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    JSONObject obj=dogtv_arr.getJSONObject("faq");
                    baike_token=obj.getString("token");
                    Intent it = new Intent();
                    it.setClass(Login2Activity.this, XiaobaikeActivity.class);
                    startActivity(it);
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        });
//        page2.chengzhang_iv1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent it = new Intent();
//                it.setClass(Login2Activity.this, ChengzhangrijiActivity.class);
//                startActivity(it);
//            }
//        });

        page5.wangwangshow_iv1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                url_wws11=true;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, ShowBofangActivity.class);
                startActivity(it);
            }
        });
        page5.wangwangshow_iv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                url_wws12=true;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, ShowBofangActivity.class);
                startActivity(it);
            }
        });
        page5.wangwangshow_iv3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                url_wws13=true;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, ShowBofangActivity.class);
                startActivity(it);
            }
        });
        page5.wangwangshow_iv4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                url_wws14=true;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, ShowBofangActivity.class);
                startActivity(it);
            }
        });
        page5.wangwangshow_iv5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                url_wws15=true;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, ShowBofangActivity.class);
                startActivity(it);
            }
        });
        page5.wangwangshow_iv6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                url_wws16=true;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, ShowBofangActivity.class);
                startActivity(it);
            }
        });
        page3.dogtv_iv1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NUM_DINGGOU=1;
                if(IF_ZHIFU){
                    DOGTV_NUM=1;
                    Intent it = new Intent();
                    it.setClass(Login2Activity.this, MainActivity.class);
                    startActivity(it);
                }else {
                    dinggou_yemian.setVisibility(View.VISIBLE);
                    translateAnimation1 = new TranslateAnimation(2000, 0, 0, 0);
                    translateAnimation1.setDuration(1000);
                    dinggou_yemian.setAnimation(translateAnimation1);
                    dinggou_anniu1.requestFocus();
                    all_foucs_no();
                }
            }
        });
        page3.dogtv_iv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NUM_DINGGOU=1;
                if(IF_ZHIFU){
                    DOGTV_NUM=2;
                    Intent it = new Intent();
                    it.setClass(Login2Activity.this, MainActivity.class);
                    startActivity(it);
                }else {
                    dinggou_yemian.setVisibility(View.VISIBLE);
                    translateAnimation1 = new TranslateAnimation(2000, 0, 0, 0);
                    translateAnimation1.setDuration(1000);
                    dinggou_yemian.setAnimation(translateAnimation1);
                    dinggou_anniu1.requestFocus();
                    all_foucs_no();
                }
            }
        });
        page3.dogtv_iv3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NUM_DINGGOU=1;
                if(IF_ZHIFU){
                    DOGTV_NUM=3;
                    Intent it = new Intent();
                    it.setClass(Login2Activity.this, MainActivity.class);
                    startActivity(it);
                }else {
                    dinggou_yemian.setVisibility(View.VISIBLE);
                    translateAnimation1 = new TranslateAnimation(2000, 0, 0, 0);
                    translateAnimation1.setDuration(1000);
                    dinggou_yemian.setAnimation(translateAnimation1);
                    dinggou_anniu1.requestFocus();
                    all_foucs_no();
                }
            }
        });
        page3.dogtv_iv4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                NUM_DINGGOU=4;
                if(IF_ZHIFU){
                    DOGTV_NUM=1;
                    Intent it = new Intent();
                    it.setClass(Login2Activity.this, MainActivity.class);
                    startActivity(it);
                }else {
                    dinggou_yemian.setVisibility(View.VISIBLE);
                    translateAnimation1 = new TranslateAnimation(2000, 0, 0, 0);
                    translateAnimation1.setDuration(1000);
                    dinggou_yemian.setAnimation(translateAnimation1);
                    dinggou_anniu1.requestFocus();
                    all_foucs_no();
                }
            }
        });
        page3.dogtv_iv5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                all_false();
                try {
                    JSONObject obj=dogtv_arr.getJSONObject("welcome");
                    dizhi=obj.getString("content_name");

                    huoqu_url(obj.getString("token"));
                    Intent it = new Intent();
                    it.setClass(Login2Activity.this, ShowBofangActivity.class);
                    startActivity(it);
                } catch (JSONException e) {
                    e.printStackTrace();
                }


            }
        });

        page2.chengzhang_gengduo_iv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chengzhang_num_pindao=0;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, JournalActivity.class);
                startActivity(it);
            }
        });
        page2.chengzhang_iv1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chengzhang_num_pindao=1;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, JournalActivity.class);
                startActivity(it);
            }
        });
        page2.chengzhang_iv2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chengzhang_num_pindao=2;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, JournalActivity.class);
                startActivity(it);
            }
        });
        page2.chengzhang_iv3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chengzhang_num_pindao=3;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, JournalActivity.class);
                startActivity(it);
            }
        });
        page2.chengzhang_iv4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                chengzhang_num_pindao=4;
                Intent it = new Intent();
                it.setClass(Login2Activity.this, JournalActivity.class);
                startActivity(it);
            }
        });
        chengzhang_queding.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                IS_SHANG = false;
                page1.IS_F1=false;
                page2.IS_F2=true;
                page3.IS_F3=false;
                page4.IS_F4=false;
                page5.IS_F5=false;
            }
        });
        tuijian_tv1.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    viewpager.setCurrentItem(0, true);
                    tuijian_tv1.setBackgroundResource(R.drawable.main_title_background_focused);
                    IS_SHANG = true;

                } else {
                    tuijian_tv1.setBackgroundDrawable(null);

                }
            }
        });
        tuijian_tv2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (hasFocus) {
                    viewpager.setCurrentItem(1, true);
                    tuijian_tv2.setBackgroundResource(R.drawable.main_title_background_focused);
                    IS_SHANG = true;

                } else {
                    tuijian_tv2.setBackgroundDrawable(null);

                }
            }
        });
        tuijian_tv3.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    viewpager.setCurrentItem(2, true);
                    tuijian_tv3.setBackgroundResource(R.drawable.main_title_background_focused);
                    IS_SHANG=true;

                }else {
                    tuijian_tv3.setBackgroundDrawable(null);


                }
            }
        });
        tuijian_tv4.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    viewpager.setCurrentItem(3,true);
                    tuijian_tv4.setBackgroundResource(R.drawable.main_title_background_focused);
                    IS_SHANG=true;

                }else {
                    tuijian_tv4.setBackgroundDrawable(null);

                }
            }
        });
        tuijian_tv5.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus){
                    viewpager.setCurrentItem(4,true);
                    tuijian_tv5.setBackgroundResource(R.drawable.main_title_background_focused);
                    IS_SHANG=true;
                }else {
                    tuijian_tv5.setBackgroundDrawable(null);


                }
            }
        });
//        page1 p1=new page1(this);
//        page2 p2=new page2(this);
//        page3 p3=new page3(this);
//        page4 p4=new page4(this);
//        page5 p5=new page5(this);

        is_dinggou();

        RequestQueue rq_2 = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
        final JsonObjectRequest request_2 = new JsonObjectRequest("http://121.201.14.248:8062/api/common/subjects/"+Product.appId+"?flavor="+ Product.flavor, null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            JSONArray arr=obj.getJSONArray("list");
                            arr_zhifubao=arr;
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                    headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };


        rq_2.add(request_2);

    }
//    private void creatAlertDialog6() {
//
//        myDialog = new AlertDialog.Builder(this).create();
//
//        myDialog.show();
//
//        myDialog.getWindow().setContentView(R.layout.diolag_faq);
//
//        myDialog.getWindow()
//                .findViewById(R.id.dia_close)
//                .setOnClickListener(new View.OnClickListener() {
//
//                    @Override
//                    public void onClick(View v) {
//
//                        myDialog.dismiss();
//                    }
//
//                });
//
//    }

    public void textcolor(){
        tuijian_tv1.setTextColor(0xffffffff);
        tuijian_tv2.setTextColor(0xffffffff);
        tuijian_tv3.setTextColor(0xffffffff);
        tuijian_tv4.setTextColor(0xffffffff);
        tuijian_tv5.setTextColor(0xffffffff);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_login2, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
    private class WangwangbaAdapter extends PagerAdapter {

            public int getCount() {
                return viewContainter.size();
            }

            //滑动切换的时候销毁当前的组件
            @Override
            public void destroyItem(ViewGroup container, int position,
            Object object) {
                ((ViewPager) container).removeView(viewContainter.get(position));
            }

            //每次滑动的时候生成的组件
            @Override
            public Object instantiateItem(ViewGroup container, int position) {
                ((ViewPager) container).addView(viewContainter.get(position));
                return viewContainter.get(position);
            }

            @Override
            public boolean isViewFromObject(View view, Object object) {
                return view == object;
            }

            @Override
            public int getItemPosition(Object object) {
                return super.getItemPosition(object);
            }
//
//            @Override
//            public float getPageWidth(int position) {
////                if(position==3){
////                    return 1;
////                }else {
//                    float num = 0.88f;
//                    return num;
////                }
//            }

    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Log.d("KeyEvent", "@@@ onKeyDown at " + event);
        if(keyCode==KeyEvent.KEYCODE_MENU){
            return true;
        }
        if(keyCode==KeyEvent.KEYCODE_DPAD_UP){
            if(page1.IS_F1){
               tuijian_tv1.requestFocus();
            }
            if(page2.IS_F2){
                tuijian_tv2.requestFocus();
            }
            if(page3.IS_F3){
                tuijian_tv3.requestFocus();
            }
            if(page4.IS_F4){
                tuijian_tv4.requestFocus();
            }
            if(page5.IS_F5){
                tuijian_tv5.requestFocus();
            }
            if(chengzhang_queding.isFocused()){
                tuijian_tv2.requestFocus();
            }
        }
        if(keyCode==KeyEvent.KEYCODE_BACK){
            if(zhifu_yemian.getVisibility()==View.VISIBLE){
                zhifu_yemian.setVisibility(View.GONE);
            }else{
                if(dinggou_yemian.getVisibility()==View.VISIBLE){
                    dinggou_yemian.setVisibility(View.GONE);
                    translateAnimation= new TranslateAnimation( 0,2000,0,0);
                    translateAnimation.setDuration(1000);
                    dinggou_yemian.setAnimation(translateAnimation);
                    all_foucs_yes();
                    dinggou_foucs();
                }
                else {
                    creatAlertDialog_tuichu();
                }
            }


            return  true;
        }


        return super.onKeyDown(keyCode, event);
    }
    private void textsizechange(){
        tuijian_tv1.setTextSize(normalSize);
        tuijian_tv2.setTextSize(normalSize);
        tuijian_tv3.setTextSize(normalSize);
        tuijian_tv4.setTextSize(normalSize);
        tuijian_tv5.setTextSize(normalSize);
    }
    /**
     * 下载app具体操作
     *
     * @param appId
     * @param downloadUrl
     * @param appName
     * @param appDesc
     * @param appSize
     */
    public void download(String appId, String downloadUrl, String appName,
                         String appDesc, long appSize) {
        // 初始化DownloadTask实例
        DownloadTask aDownloadTask = new DownloadTask(appId,
                Uri.parse(downloadUrl), appName, appDesc, appSize);
        // 实例化DownloadManager.Request
        DownloadManager.Request request = new DownloadManager.Request(
                aDownloadTask.getDownloadURI());
        // 系统下载路径
        request.setDestinationInExternalFilesDir(Login2Activity.this,
                Environment.DIRECTORY_DOWNLOADS, appName + ".apk");

        // request.setShowRunningNotification(true);
        // 向队列加载一个新的下载项
        DownloadManager downloadManager = ((DownloadManager) Login2Activity.this
                .getSystemService(DOWNLOAD_SERVICE));
        long downloadId = downloadManager.enqueue(request);
        // 保存downloadId
        aDownloadTask.setDownloadId(downloadId);
        // 保存DownloadTask对象
        // tasks.add(aDownloadTask);
        // 过滤器 当前下载任务完成
        IntentFilter filter = new IntentFilter(
                DownloadManager.ACTION_DOWNLOAD_COMPLETE);
        // 注册并监听过滤器
        Login2Activity.this.registerReceiver(receiver, filter);

    }
    private void updataAPK(String url,final int currVersion){
        receiver=new DownloadTaskReceiver();
        JsonObjectRequest mJsonObjectRequest = new JsonObjectRequest(url, null,
                new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject obj) {
                        try {
                            JSONObject response=obj.getJSONObject("data");

                            // 版本是否更新 0否 1是
                            String versionName = response.getString("versionName");
                            if (AppUtil.converVersionNameToInt(versionName) > currVersion) {
                                // 获取apk下载地址
                                final String apkUpdateUrl = response
                                        .getString("apk");
                                // 是否强制更新 0否 1是
                                int isForceUpdate = response
                                        .getInt("isForce");

                                AlertDialog.Builder b2 = new AlertDialog.Builder(
                                        Login2Activity.this)
                                        .setTitle("提示")
                                        .setMessage("升级到最新版本")
                                        .setPositiveButton(
                                                "确定",
                                                new AlertDialog.OnClickListener() {
                                                    public void onClick(
                                                            DialogInterface dialog,
                                                            int which) {
                                                        Toast.makeText(
                                                                Login2Activity.this,
                                                                "开始下载！",
                                                                Toast.LENGTH_LONG)
                                                                .show();
                                                        download("",
                                                                apkUpdateUrl,
                                                                "wangwangba",
                                                                "", 0);
                                                    }
                                                });

                                if (isForceUpdate == 0) {
                                    b2.setNegativeButton("取消",
                                            new AlertDialog.OnClickListener() {

                                                @Override
                                                public void onClick(
                                                        DialogInterface dialog,
                                                        int which) {
                                                    dialog.dismiss();
                                                }
                                            });
                                    b2.setCancelable(true);
                                } else {
                                    b2.setCancelable(false);
                                }
                                b2.create();
                                b2.show();
                            }

                        } catch (NumberFormatException e) {
                            e.printStackTrace();
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Toast.makeText(Login2Activity.this, "更新访问失败！",
                        Toast.LENGTH_LONG).show();
            }
        });

        // 将 请求放入 请求队列
        AppUtil.getInstance(this).getRequestQueue().add(mJsonObjectRequest);
    }

    public static void all_false(){
        url_wws11=false;
        url_wws12=false;
        url_wws13=false;
        url_wws14=false;
        url_wws15=false;
        url_wws16=false;
        url_wws17=false;
        url_wws18=false;
        url_wws19=false;
        url_wws110=false;
    }

    private void creatAlertDialog_tuichu() {

        myDialog = new AlertDialog.Builder(this).create();

        myDialog.show();

        myDialog.getWindow().setContentView(R.layout.diolag_tuichu);

        myDialog.getWindow()
                .findViewById(R.id.no_iv)
                .setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        myDialog.dismiss();

                    }

                });
        myDialog.getWindow()
                .findViewById(R.id.yes_iv)
                .setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        myDialog.dismiss();
                            finish();

                    }

                });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        mMessengerClient.unbind(this);
        mMessengerClient.release(this);

        Iterator iter = map.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next(); Object key = entry.getKey();
            Object val = entry.getValue();
            Bitmap a=(Bitmap)val;
            a.recycle();
        }
        System.gc();
    }

    @Override
    protected void onResume() {
        super.onResume();
//        MiStatInterface.recordPageStart(this, "Login2Activity");
    }

    @Override
    protected void onPause() {
        super.onPause();
//        MiStatInterface.recordPageEnd();
    }
    public void image_fangda(View v, boolean hasFocus){
        if (hasFocus) {
            v.getParent().bringChildToFront(v);

            Animation ani = AnimationUtils.loadAnimation(v.getContext(),
                    R.anim.bar_scale_new);
            ani.setFillAfter(true);

            v.startAnimation(ani);


        } else {
            Animation ani = AnimationUtils.loadAnimation(v.getContext(),
                    R.anim.bar_scale_in_new);
            ani.setFillAfter(true);
            v.startAnimation(ani);

        }
    }
    private void all_foucs_no(){
        tuijian_tv1.setFocusable(false);
        tuijian_tv2.setFocusable(false);
        tuijian_tv3.setFocusable(false);
        tuijian_tv4.setFocusable(false);
        tuijian_tv5.setFocusable(false);
        page1.tuijian_iv1.setFocusable(false);
        page1.tuijian_iv2.setFocusable(false);
        page1.tuijian_iv3.setFocusable(false);
        page1.tuijian_iv4.setFocusable(false);
        page3.dogtv_iv1.setFocusable(false);
        page3.dogtv_iv2.setFocusable(false);
        page3.dogtv_iv3.setFocusable(false);
        page3.dogtv_iv4.setFocusable(false);
        page3.dogtv_iv5.setFocusable(false);
        page3.dogtv_iv6.setFocusable(false);
        page4.baike_iv1.setFocusable(false);
        page4.baike_iv2.setFocusable(false);
        page4.baike_iv3.setFocusable(false);
        page4.baike_iv4.setFocusable(false);
        page4.baike_iv5.setFocusable(false);
        page5.wangwangshow_iv1.setFocusable(false);
        page5.wangwangshow_iv2.setFocusable(false);
        page5.wangwangshow_iv3.setFocusable(false);
        page5.wangwangshow_iv4.setFocusable(false);
        page5.wangwangshow_iv5.setFocusable(false);
        page5.wangwangshow_iv6.setFocusable(false);
        page2.chengzhang_gengduo_iv.setFocusable(false);
        page2.chengzhang_iv1.setFocusable(false);
        page2.chengzhang_iv2.setFocusable(false);
        page2.chengzhang_iv3.setFocusable(false);
        page2.chengzhang_iv4.setFocusable(false);
    }
    private void all_foucs_yes(){
        tuijian_tv1.setFocusable(true);
        tuijian_tv2.setFocusable(true);
        tuijian_tv3.setFocusable(true);
        tuijian_tv4.setFocusable(true);
        tuijian_tv5.setFocusable(true);
        page1.tuijian_iv1.setFocusable(true);
        page1.tuijian_iv2.setFocusable(true);
        page1.tuijian_iv3.setFocusable(true);
        page1.tuijian_iv4.setFocusable(true);
        page3.dogtv_iv1.setFocusable(true);
        page3.dogtv_iv2.setFocusable(true);
        page3.dogtv_iv3.setFocusable(true);
        page3.dogtv_iv4.setFocusable(true);
        page3.dogtv_iv5.setFocusable(true);
        page3.dogtv_iv6.setFocusable(true);
        page4.baike_iv1.setFocusable(true);
        page4.baike_iv2.setFocusable(true);
        page4.baike_iv3.setFocusable(true);
        page4.baike_iv4.setFocusable(true);
        page4.baike_iv5.setFocusable(true);
        page5.wangwangshow_iv1.setFocusable(true);
        page5.wangwangshow_iv2.setFocusable(true);
        page5.wangwangshow_iv3.setFocusable(true);
        page5.wangwangshow_iv4.setFocusable(true);
        page5.wangwangshow_iv5.setFocusable(true);
        page5.wangwangshow_iv6.setFocusable(true);
        page2.chengzhang_gengduo_iv.setFocusable(true);
        page2.chengzhang_iv1.setFocusable(true);
        page2.chengzhang_iv2.setFocusable(true);
        page2.chengzhang_iv3.setFocusable(true);
        page2.chengzhang_iv4.setFocusable(true);
    }
    private void dinggou_foucs(){
        if(NUM_DINGGOU==1){
            page3.dogtv_iv1.requestFocus();
        }else if(NUM_DINGGOU==2){
            page3.dogtv_iv2.requestFocus();
        }else if(NUM_DINGGOU==3){
            page3.dogtv_iv3.requestFocus();
        }else if(NUM_DINGGOU==4){
            page3.dogtv_iv4.requestFocus();
        }
    }
    private void is_dinggou(){
        RequestQueue rq_1 = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
        final JsonObjectRequest request_1 = new JsonObjectRequest("http://121.201.14.248:8062/api/common/wpay/check/"+Product.appId+"?userid="+ Util.getDeviceId(Login2Activity.this), null,
                new Response.Listener<JSONObject>() {

                    @Override
                    public void onResponse(JSONObject jsonObject) {
                        try {
                            JSONObject obj=jsonObject.getJSONObject("data");
                            IF_ZHIFU=obj.getBoolean("payCompleted");
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError volleyError) {

            }
        }

        ) {
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                PackageInfo pi= null;
                try {
                    pi = Login2Activity.this.getPackageManager().getPackageInfo(Login2Activity.this.getPackageName(), 0);
                    headers.put("accept", "applicationnd.com.wanbatv.wangwangba;version="+pi.versionName);
                    headers.put("app_version", pi.versionName);
                    headers.put("app_package_name",pi.packageName);
                } catch (PackageManager.NameNotFoundException e) {
                    e.printStackTrace();
                }


                // MyLog.d(TAG, "headers=" + headers);
                return headers;
            }
        };


        rq_1.add(request_1);
    }

    private void chengzhangjirishuaxin(JSONObject jsonObject,final View view2){
        try {
            JSONArray arr=jsonObject.getJSONArray("userList");

            if(arr.length()>0) {
                JSONObject obj = arr.getJSONObject(0);
                final ImageView iv = (ImageView) view2.findViewById(R.id.chengzhang_touxiang_iv);
                TextView tv = (TextView) view2.findViewById(R.id.chengzhang_xingming_tv);
                tv.setText(obj.getString("nickName"));
                RequestQueue mQueue = Volley.newRequestQueue(Login2Activity.this);

                ImageRequest imageRequest = new ImageRequest(
                        obj.getString("avatar"),
                        new Response.Listener<Bitmap>() {
                            @Override
                            public void onResponse(Bitmap response) {
                                iv.setImageBitmap(response);
                                map.put("dogtv_iv_touxiang", response);
                            }
                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                    }
                });
                mQueue.add(imageRequest);
            }
//                                                        JSONObject obj1=jsonObject.getJSONObject("qrcode");
            RequestQueue mQueue1 = Volley.newRequestQueue(Login2Activity.this);

            ImageRequest imageRequest1 = new ImageRequest("http://121.201.14.248"+
                    jsonObject.getString("qrUrl"),
                    new Response.Listener<Bitmap>() {
                        @Override
                        public void onResponse(Bitmap response) {
                            ImageView iv1=(ImageView)view2.findViewById(R.id.chengzhang_erweima_iv);
                            iv1.setImageBitmap(response);
                            map.put("dogtv_iv_erweima", response);
                        }
                    }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                }
            });
            mQueue1.add(imageRequest1);
            JSONArray arr_photo=jsonObject.getJSONArray("mediaList");
            JSONArray arr1=new JSONArray();
            JSONArray arr2=new JSONArray();
            JSONArray arr3=new JSONArray();
            JSONArray arr4=new JSONArray();
            String a1=null;
            String a2=null;
            String a3=null;
            String a4=null;
            JSONArray arr1_video=new JSONArray();
            JSONArray arr2_video=new JSONArray();
            JSONArray arr3_video=new JSONArray();
            JSONArray arr4_video=new JSONArray();
            for (int i=0;i<arr_photo.length();i++){
                JSONObject obj_photo=arr_photo.getJSONObject(i);
                if(i==0){
                    a1=obj_photo.getString("uploadDate");
                }
                if(a1!=null){
                    if(obj_photo.getString("uploadDate").equals(a1)){
                        if(obj_photo.getString("mediaType").equals("video")){
                            arr1_video.put(obj_photo);
                        }else {
                            arr1.put(obj_photo);
                        }
                    }else{
                        if(a2==null) {
                            a2 = obj_photo.getString("uploadDate");
                        }
                    }
                }
                if(a2!=null){
                    if(obj_photo.getString("uploadDate").equals(a2)){
                        if(obj_photo.getString("mediaType").equals("video")){
                            arr2_video.put(obj_photo);
                        }else {
                            arr2.put(obj_photo);
                        }
                    }else{
                        if(a3==null) {
                            a3 = obj_photo.getString("uploadDate");
                        }
                    }
                }
                if(a3!=null){
                    if(obj_photo.getString("uploadDate").equals(a3)){
                        if(obj_photo.getString("mediaType").equals("video")){
                            arr3_video.put(obj_photo);
                        }else {
                            arr3.put(obj_photo);
                        }
                    }else{
                        if(a4==null) {
                            a4 = obj_photo.getString("uploadDate");
                        }
                    }
                }
                if(a4!=null){
                    if(obj_photo.getString("uploadDate").equals(a4)){
                        if(obj_photo.getString("mediaType").equals("video")){
                            arr4_video.put(obj_photo);
                        }else {
                            arr4.put(obj_photo);
                        }
                    }
                }
            }
            chengzhang_num1=arr1_video.length()+arr1.length();
            chengzhang_num2=chengzhang_num1+arr1_video.length()+arr1.length();
            chengzhang_num3=chengzhang_num2+arr1_video.length()+arr1.length();
            chengzhang_num4=chengzhang_num3+arr1_video.length()+arr1.length();

            if(arr1.length()>0 || arr1_video.length()>0){
                JSONObject obj_1=null;
                String img_url=null;
                if(arr1.length()>0){
                    obj_1=arr1.getJSONObject(0);
                    img_url=obj_1.getString("src");
                }else{
                    obj_1=arr1_video.getJSONObject(0);
                    img_url=obj_1.getString("iconSrc");
                }
                RequestQueue mQueue11 = Volley.newRequestQueue(Login2Activity.this);
                ImageRequest imageRequest11 = new ImageRequest(
                        img_url,
                        new Response.Listener<Bitmap>() {
                            @Override
                            public void onResponse(Bitmap response) {
                                page2.chengzhang_iv1.setImageBitmap(response);
                                map.put("chengzhang_iv1", response);
                            }
                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                    }
                });
                mQueue11.add(imageRequest11);
                page2.chengzhang_tv11.setText(obj_1.getString("uploadDate"));
                page2.chengzhang_tv12.setText("您发布了"+arr1.length()+"张照片，"+arr1_video.length()+"个视频");
            }else{
                page2.chengzhang_tv11.setText("无");
            }

            if(arr2.length()>0|| arr2_video.length()>0){
                JSONObject obj_2=null;
                String img_url=null;
                if(arr2.length()>0){
                    obj_2=arr2.getJSONObject(0);
                    img_url=obj_2.getString("src");
                }else{
                    obj_2=arr2_video.getJSONObject(0);
                    img_url=obj_2.getString("iconSrc");
                }

                RequestQueue mQueue12 = Volley.newRequestQueue(Login2Activity.this);
                ImageRequest imageRequest12 = new ImageRequest(
                        img_url,
                        new Response.Listener<Bitmap>() {
                            @Override
                            public void onResponse(Bitmap response) {
                                page2.chengzhang_iv2.setImageBitmap(response);
                                map.put("chengzhang_iv2", response);
                            }
                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                    }
                });
                mQueue12.add(imageRequest12);
                page2.chengzhang_tv21.setText(obj_2.getString("uploadDate"));
                page2.chengzhang_tv22.setText("您发布了"+arr2.length()+"张照片，"+arr2_video.length()+"个视频");
            }else{
                page2.chengzhang_tv21.setText("无");
            }

            if(arr3.length()>0|| arr3_video.length()>0){
                JSONObject obj_3=null;
                String img_url=null;
                if(arr3.length()>0){
                    obj_3=arr3.getJSONObject(0);
                    img_url=obj_3.getString("src");
                }else{
                    obj_3=arr3_video.getJSONObject(0);
                    img_url=obj_3.getString("iconSrc");
                }
                RequestQueue mQueue13 = Volley.newRequestQueue(Login2Activity.this);
                ImageRequest imageRequest13 = new ImageRequest(
                        img_url,
                        new Response.Listener<Bitmap>() {
                            @Override
                            public void onResponse(Bitmap response) {
                                page2.chengzhang_iv3.setImageBitmap(response);
                                map.put("chengzhang_iv3", response);
                            }
                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                    }
                });
                mQueue13.add(imageRequest13);
                page2.chengzhang_tv31.setText(obj_3.getString("uploadDate"));
                page2.chengzhang_tv32.setText("您发布了"+arr3.length()+"张照片，"+arr3_video.length()+"个视频");
            }else{
                page2.chengzhang_tv31.setText("无");
            }
            if(arr4.length()>0|| arr4_video.length()>0){
                JSONObject obj_4=null;
                String img_url=null;
                if(arr4.length()>0){
                    obj_4=arr4.getJSONObject(0);
                    img_url=obj_4.getString("src");
                }else{
                    obj_4=arr4_video.getJSONObject(0);
                    img_url=obj_4.getString("iconSrc");
                }
                RequestQueue mQueue14 = Volley.newRequestQueue(Login2Activity.this);
                ImageRequest imageRequest14 = new ImageRequest(
                       img_url,
                        new Response.Listener<Bitmap>() {
                            @Override
                            public void onResponse(Bitmap response) {
                                page2.chengzhang_iv4.setImageBitmap(response);
                                map.put("chengzhang_iv4", response);
                            }
                        }, 0, 0, Bitmap.Config.RGB_565, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
//                                    erweima_login.setImageResource(R.drawable.default_image);
                    }
                });
                mQueue14.add(imageRequest14);
                page2.chengzhang_tv41.setText(obj_4.getString("uploadDate"));
                page2.chengzhang_tv42.setText("您发布了"+arr4.length()+"张照片，"+arr4_video.length()+"个视频");
            }else{
                page2.chengzhang_tv41.setText("无");
            }


        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void onStart() {
        super.onStart();
        if(view_shuaxin!=null){
            RequestQueue rq = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
            JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wangwangba/data.jsp?userId="+ Util.getDeviceId(Login2Activity.this), null,
                    new Response.Listener<JSONObject>() {

                        @Override
                        public void onResponse(JSONObject jsonObject) {
                            chengzhangjirishuaxin(jsonObject,view_shuaxin);
                        }
                    }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                }
            }

            );
            rq.add(request);
        }
        mMessengerClient.subscribeMessage(this, mMessageSubscriber);
    }

    @Override
    protected void onStop() {
        super.onStop();
        mMessengerClient.unsubscribeMessage(mMessageSubscriber);
    }

    private void createImage(ImageView v,String t) {
        try {
            // 需要引入core包
            QRCodeWriter writer = new QRCodeWriter();

            String text = t;


            if (text == null || "".equals(text) || text.length() < 1) {
                return;
            }
            int QR_WIDTH=v.getWidth();
            int QR_HEIGHT= v.getHeight();
            // 把输入的文本转为二维码
            BitMatrix martix = writer.encode(text, BarcodeFormat.QR_CODE,
                    QR_WIDTH, QR_HEIGHT);

            System.out.println("w:" + martix.getWidth() + "h:"
                    + martix.getHeight());

            Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
            hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
            BitMatrix bitMatrix = new QRCodeWriter().encode(text,
                    BarcodeFormat.QR_CODE, QR_WIDTH, QR_HEIGHT, hints);
            int[] pixels = new int[QR_WIDTH * QR_HEIGHT];
            for (int y = 0; y < QR_HEIGHT; y++) {
                for (int x = 0; x < QR_WIDTH; x++) {
                    if (bitMatrix.get(x, y)) {
                        pixels[y * QR_WIDTH + x] = 0xff000000;
                    } else {
                        pixels[y * QR_WIDTH + x] = 0xffffffff;
                    }

                }
            }

            Bitmap bitmap = Bitmap.createBitmap(QR_WIDTH, QR_HEIGHT,
                    Bitmap.Config.ARGB_8888);

            bitmap.setPixels(pixels, 0, QR_WIDTH, 0, 0, QR_WIDTH, QR_HEIGHT);
            v.setImageBitmap(bitmap);

        } catch (WriterException e) {
            e.printStackTrace();
        }
    }

    private class MessageSubscriberImpl extends MessageSubscriber {

        @Override
        public void onReceiveMessage(Context context, String tag, Letter message) {
            Log.d("PUSH", "@@@ tag " + tag);
            if (tag.equals("alipay.trade.precreate")) {
                //TODO 支付完成后的推送数据在这里处理
                IF_ZHIFU=true;
                zhifu_yemian.setVisibility(View.GONE);
                dinggou_yemian.setVisibility(View.GONE);
                all_foucs_yes();
                dinggou_foucs();
                translateAnimation= new TranslateAnimation( 0,2000,0,0);
                translateAnimation.setDuration(1000);
                dinggou_yemian.setAnimation(translateAnimation);
                translateAnimation.setAnimationListener(new Animation.AnimationListener() {
                    @Override
                    public void onAnimationStart(Animation animation) {

                    }

                    @Override
                    public void onAnimationEnd(Animation animation) {
                        DOGTV_NUM=NUM_DINGGOU;
                        Intent it = new Intent();
                        it.setClass(Login2Activity.this, MainActivity.class);
                        startActivity(it);
                    }

                    @Override
                    public void onAnimationRepeat(Animation animation) {

                    }
                });
            } else if (tag.equals("wangwangba.journal.add")) {
                //TODO 用户在微信客户端发照片或视频后会收到通知
                if(view_shuaxin!=null){
                    RequestQueue rq = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
                    JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wangwangba/data.jsp?userId="+ Util.getDeviceId(Login2Activity.this), null,
                            new Response.Listener<JSONObject>() {

                                @Override
                                public void onResponse(JSONObject jsonObject) {
                                    chengzhangjirishuaxin(jsonObject,view_shuaxin);
                                }
                            }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError volleyError) {
                        }
                    }

                    );
                    rq.add(request);
                }
            } else if (tag.equals("wangwangba.journal.bind")) {
                //TODO 用户扫二维码绑定终端后收到通知

                RequestQueue rq = Volley.newRequestQueue(Login2Activity.this.getApplicationContext());
                JsonObjectRequest request = new JsonObjectRequest("http://121.201.14.248/wangwangba/data.jsp?userId="+ Util.getDeviceId(Login2Activity.this), null,
                        new Response.Listener<JSONObject>() {

                            @Override
                            public void onResponse(JSONObject jsonObject) {
                                chengzhangjirishuaxin(jsonObject,view_shuaxin);

                                try {
                                    JSONArray arr=jsonObject.getJSONArray("userList");

                                    if(arr.length()==0){
                                        Toast.makeText(Login2Activity.this,"请先扫描二维码",Toast.LENGTH_LONG).show();
                                    }else{

                                        if(chengzhang_rela2.getVisibility()==View.VISIBLE) {
                                            chengzhang_rela1.setVisibility(View.VISIBLE);
                                            chengzhang_rela2.setVisibility(View.GONE);
                                            chengzhangjirishuaxin(jsonObject, view_shuaxin);
                                            tuijian_tv2.requestFocus();
                                        }
                                    }
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }

                            }
                        }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError volleyError) {
                    }
                }

                );
                rq.add(request);
            }
        }

    }
    private void houtaibangding(final JSONArray arr){
        String name="";
        StringBuilder stringBuilder=new StringBuilder();
        for (int i=0;i<arr.length();i++){
            try {
                JSONObject obj=arr.getJSONObject(i);
                stringBuilder.append(obj.getString("weixinId")).append(",");


            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        name=stringBuilder.toString();
        RequestQueue requestQueue = Volley.newRequestQueue(Login2Activity.this);
        String url="http://121.201.14.248:8062/api/wangwangba/journal/binds";
        final String finalName = name;
        StringRequest stringRequest = new StringRequest(com.android.volley.Request.Method.POST,url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        Log.e("@@@","response:"+response);
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        }) {
            @Override
            protected Map<String, String> getParams() {
                //在这里设置需要post的参数

                Map<String, String> map = new HashMap<String, String>();
                map.put("stb",Util.getDeviceId(Login2Activity.this));
                map.put("wxuserids", finalName);
                return map;
            }
        };
        requestQueue.add(stringRequest);
    }
}
